# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
#   movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
#   Character.create(name: 'Luke', movie: movies.first)

if false
  puts "正在写入测试数据..."
  p0 = Person.create(name:"p0",email:"p0@mail.com",age:25)
  p1 = Person.create(name:"p1",email:"p1@mail.com",age:25)
  p2 = Person.create(name:"p2",email:"p2@mail.com",age:25)
  p3 = Person.create(name:"p3",email:"p3@mail.com",age:25)
  p4 = Person.create(name:"p4",email:"p4@mail.com",age:25)

  wtk = Unit.create(name:"网通科",level:2,remark:"wtk")
  wlz = Unit.create(name:"网络组",level:1,remark:"wlz")
  txz = Unit.create(name:"通讯组",level:1,remark:"txz")

  wlz.person.append(p0)
  wlz.person.append(p1)
  wlz.person.append(p2)

  txz.person.append(p3)
  txz.person.append(p4)

  wtk.sub_unit.append(wlz)
  wtk.sub_unit.append(txz)

  dzzx = Unit.create(name:"电子中心",level:2,remark:"dzzx")
  dzzx.sub_unit.create(name:"离岗组",level:1,remark:"lgz")
  dzzx.sub_unit.create(name:"生产组",level:1,remark:"scz")
  dzzx.sub_unit.create(name:"安防组",level:1,remark:"afz")

  sbk1 = Unit.create(name:"设备一科",level:2,remark:"sbk1")
  sbk2 = Unit.create(name:"设备二科",level:2,remark:"sbk2")
  dhk = Unit.create(name:"导航科",level:2,remark:"dhk")

  jdb = Unit.create(name:"机电部",level:3,remark:"jdb")
  jdb.sub_unit.append(wtk)
  jdb.sub_unit.append(dzzx)
  jdb.sub_unit.append(sbk1)
  jdb.sub_unit.append(sbk2)
  jdb.sub_unit.append(dhk)

  hgb = Unit.create(name:"候管部",level:3,remark:"hgb")
  zbb = Unit.create(name:"综保部",level:3,remark:"zbb")
  jwgcb = Unit.create(name:"机务工程部",level:3,remark:"jwgcb")
  aoc = Unit.create(name:"现场指挥中心",level:3,remark:"aoc")

  hffgs = Unit.create(name:"合肥分公司",level:4,remark:"hffgs")
  hffgs.sub_unit.append(jdb)
  hffgs.sub_unit.append(hgb)
  hffgs.sub_unit.append(zbb)
  hffgs.sub_unit.append(jwgcb)
  hffgs.sub_unit.append(aoc)

  khgs = Unit.create(name:"客货公司",level:4,remark:"khgs")
  scb = Unit.create(name:"市场部",level:4,remark:"scb")
  ghb = Unit.create(name:"规划部",level:4,remark:"ghb")
  rlzyb = Unit.create(name:"人力资源部",level:4,remark:"rlzyb")

  jtgs = Unit.create(name:"集团公司",level:5,remark:"jtks")
  jtgs.sub_unit.append(hffgs)
  jtgs.sub_unit.append(khgs)
  jtgs.sub_unit.append(scb)
  jtgs.sub_unit.append(ghb)
  jtgs.sub_unit.append(rlzyb)

  puts "写入测试数据完毕！"
end
